package com.cuitrip.business.share.ui;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.cuitrip.business.share.ShareChannelBuilder;
import com.cuitrip.business.share.model.Share;
import com.cuitrip.service.R;
import com.cuitrip.util.adapter.CTRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ak on 15/11/24.
 */
public class ShareAdapter extends CTRecyclerAdapter<ShareItemView> {

    private static enum ITEM_TYPE{
        share,
        more;
    }

    private List<ShareChannelBuilder.TripShareChannel> shareList = new ArrayList<>();

    public void setShareList(List<ShareChannelBuilder.TripShareChannel> shareList) {
        if (shareList == null) {
            shareList = new ArrayList<>();
        }
        this.shareList = shareList;
        notifyDataSetChanged();
    }

    public List<ShareChannelBuilder.TripShareChannel> getShareList() {
        return shareList;
    }

    public ShareItemView newViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.share_item, parent, false);
        ShareItemView vh = new ShareItemView(view);
        return vh;
    }

    @Override
    public void onBindViewHolder(ShareItemView holder, int position) {
        holder.render(shareList.get(position));
    }

    @Override
    public int getItemCount() {
        return shareList == null ? 0 : shareList.size();
    }
}


